Analysis date: 2023-02-07

Depends on

CRC_Xenografts_FirstBatch_DataProcessing Script

#set.seed(2022)
load("../Data/Cache/Xenografts_Batch1_2_DataProcessing.RData")

Setup

Load libraries

Functions

General

source("../../../General/Code/Analysis_Functions.R")
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6      ✔ purrr   0.3.5 
## ✔ tibble  3.1.8      ✔ dplyr   1.0.10
## ✔ tidyr   1.2.1      ✔ stringr 1.4.1 
## ✔ readr   2.1.3      ✔ forcats 0.5.2 
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::collapse()   masks IRanges::collapse()
## ✖ dplyr::combine()    masks Biobase::combine(), BiocGenerics::combine()
## ✖ dplyr::count()      masks matrixStats::count()
## ✖ dplyr::desc()       masks IRanges::desc()
## ✖ tidyr::expand()     masks S4Vectors::expand()
## ✖ dplyr::filter()     masks stats::filter()
## ✖ dplyr::first()      masks S4Vectors::first()
## ✖ dplyr::lag()        masks stats::lag()
## ✖ purrr::map()        masks kohonen::map()
## ✖ ggplot2::Position() masks BiocGenerics::Position(), base::Position()
## ✖ purrr::reduce()     masks GenomicRanges::reduce(), IRanges::reduce()
## ✖ dplyr::rename()     masks S4Vectors::rename()
## ✖ dplyr::select()     masks AnnotationDbi::select()
## ✖ dplyr::slice()      masks IRanges::slice()
source("CRC_Xenografts_Batch1_Functions.R")

SOMs

Train_SOM <- function(phos_mat, try.k){
  ## define a grid for the SOM and train
  grid.size <- ceiling(nrow(phos_mat ) ^ (1/2.5))
  som.grid <- somgrid(xdim = grid.size, ydim = grid.size, topo =   'hexagonal', toroidal = T)
  som.model <- som(data.matrix(phos_mat ), grid = som.grid)
  
  ## extract some data to make it easier to use
  som.events <- som.model$codes[[1]]
  #som.events.colors <- rgb(som.events[,1], som.events[,2],   som.events[,3], maxColorValue = 255)
  som.dist <- as.matrix(dist(som.events))
  
  
  plot(som.model, type = 'mapping', cex=0.2)
  plot(som.model, type="changes")
  plot(som.model, type = 'count')
  plot(som.model, type="dist.neighbours")
  # plot(som.model, type="codes") 
  # dev.off()
  #plot(som.model, type = "property", property = som.model$codes[,4],   main=names(som.model$data)[4]#, palette.name=coolBlueHotRed
  
  #try.k <- 2:100
  cluster.dist.eval <- as.data.frame(matrix(ncol = 3, nrow = (length(try.k))))
  colnames(cluster.dist.eval) <- c('k', 'kmeans', 'hclust')
  
  for(i in 1:length(try.k)) {
    cluster.dist.eval[i, 'k'] <- try.k[i]
    cluster.dist.eval[i, 'kmeans'] <- Cluster_Mean_Dist(kmeans(som.events, centers   = try.k[i], iter.max = 20)$cluster, som.dist = som.dist)
    cluster.dist.eval[i, 'hclust'] <-   Cluster_Mean_Dist(cutree(hclust(vegan::vegdist(som.events)), k = try.k[i]),   som.dist = som.dist)
  }
  
  plot(cluster.dist.eval[, 'kmeans'] ~ try.k,
       type = 'l')
  
  lines(cluster.dist.eval[, 'hclust'] ~ try.k,
        col = 'red')
  
  legend('topright',
         legend = c('k-means', 'hierarchical'),
         col = c('black', 'red'),
         lty = c(1, 1))
  
  return(list( som.model, som.events ))
}

## Define a function to calculate mean distance within each cluster.  This
## is roughly analogous to the within clusters ss approach
Cluster_Mean_Dist <- function(clusters, som.dist){
  cluster.means = c()
  
  for(c in unique(clusters)){
    temp.members <- which(clusters == c)
    
    if(length(temp.members) > 1){
      temp.dist <- som.dist[temp.members,]
      temp.dist <- temp.dist[,temp.members]
      cluster.means <- append(cluster.means, mean(temp.dist))
    }else(cluster.means <- 0)
  }
  
  return(mean(cluster.means))
  
}

Plot_Colored_SOM <- function(som.model, clusters, type = "mapping", cl = 40){
  plot(som.model, 
       type = type, 
       pchs = 21, 
       cex=0.2,
       col = "black",
       #bg = c("blue" , "red", "yellow", "green")[as.factor(str_remove(str_split( rownames(som.model$data[[1]]), "-", simplify = T )[,1], "log2FC_")) ] , 
       keepMargins = F,
       bgcol = c(RColorBrewer::brewer.pal(12, "Set3"), RColorBrewer::brewer.pal(9, "Set1"), RColorBrewer::brewer.pal(8, "Set2"), RColorBrewer::brewer.pal(9, "Pastel1"), RColorBrewer::brewer.pal(8, "Dark2"))[clusters]  )
  
    add.cluster.boundaries(som.model, clusters)
}

Asign_To_Clusters <- function(som.model, clusters){
  cluster_classification <- som.model$unit.classif
  names(cluster_classification) <- rownames(som.model$data[[1]])
  classification <- clusters[cluster_classification]
  names(classification) <- rownames(som.model$data[[1]])
  classification
}

Get_Members_Of_One_Cluster <- function(som.model, clusters, n){
  message(paste("Cluster" , n ))
  asign <- Asign_To_Clusters(som.model, clusters)
  names(asign[asign == n])
}

Get_Mat_With_Assigned_Clusters <- function(som.model, clusters, phos_mat ){
  som.cluster.asignedclusters <- Asign_To_Clusters(som.model = som.model, 
                 clusters = clusters) 
  
  phos_mat_t <- as.data.frame( t(phos_mat) )
  phos_mat_t$cluster <-   som.cluster.asignedclusters[rownames(phos_mat_t)]
    
  phos_mat_t <- phos_mat_t %>%
      rownames_to_column( "peptide") %>%
      pivot_longer(-c(peptide, cluster), names_to = "sample", values_to = "log2FC")   %>%
      mutate(sample = gsub( "log2FC_", "", sample)) %>%
      separate( sample , into = c("xenograft", "treatment", "day", "replicate", "set"), sep = "_", remove = F) %>%
      separate(peptide, into = c("HGNC_Symbol", "Annotated_Sequence"), sep = "_",   remove = F ) %>%
      mutate(treatment = as.factor(treatment)) 
  return(phos_mat_t)
}

Plot_Profiles_SOM_clusters <- function(som.model, clusters, phos_mat, ncol_grid=4, specific_cluster = FALSE ){
    phos_mat_t <- Get_Mat_With_Assigned_Clusters(som.model, clusters, phos_mat)
    phos_mat_t <- phos_mat_t
  
  mean_per_type <- 
    phos_mat_t %>%
    group_by(sample, treatment) %>%
    summarise(log2FC= median(log2FC)) %>%
    ungroup() %>%
    group_by(treatment) %>%
    summarise(mean_log2FC = mean(log2FC)) %>%
    ungroup() %>%
    column_to_rownames("treatment") %>% 
    t %>% as_tibble()
  
  if(specific_cluster){
    phos_mat_t <- phos_mat_t %>% 
      filter(cluster==specific_cluster)
  }
  
  phos_mat_t %>% 
    filter(!is.na(cluster)) %>%
    mutate(treatment = as.factor(treatment)) %>%
    mutate(treatment = factor(treatment, levels = c("ctrl", "E", "EC", "EBC"))) %>%
      #filter(cluster==19) %>%
      ggplot(aes( sample, log2FC, fill = treatment, group = peptide )) +
      geom_line(alpha = 0.3) +
      theme_bw() +
      theme(axis.text.x = element_text(angle = 90),
            axis.title.x = element_blank()) +
      scale_color_manual(values = PGPalette[c(5,1,2,4)]) +
      facet_wrap(~cluster, ncol = ncol_grid) +
      geom_hline(col = PGPalette[5], yintercept = mean_per_type$ctrl) +
      geom_hline(col = PGPalette[1], yintercept = mean_per_type$E) +
      geom_hline(col = PGPalette[2], yintercept = mean_per_type$EC) +
      geom_hline(col = PGPalette[4], yintercept = mean_per_type$EBC) +
    geom_point(alpha = 0.3, aes(col = treatment), size = 0.4)
}

Plot_Profiles_SOM_Clusters_Splitbyday <- function(som.model, clusters, phos_mat, ncol_grid=4, specific_cluster = FALSE ){
    phos_mat_t <- Get_Mat_With_Assigned_Clusters(som.model, clusters, phos_mat)
    phos_mat_t <- phos_mat_t
  
  if(specific_cluster){
    phos_mat_t <- phos_mat_t %>% 
      filter(cluster==specific_cluster)
  }
  
  phos_mat_t %>% 
    filter(!is.na(cluster)) %>%
      #filter(cluster==19) %>%
      mutate(prep = unlist(prep_l[sample]), 
             treatment = as.factor(treatment) ) %>%
    mutate(treatment = factor(treatment, levels = c("ctrl", "E", "EC", "EBC"))) %>%
      group_by(treatment, day, sample, cluster) %>%
      summarise(log2FC= mean(log2FC)) %>%
      ungroup() %>%
      ggplot(aes( treatment, log2FC, fill = treatment )) +
      geom_boxplot(outlier.size = 0) +
      theme_bw() +
      scale_fill_manual(values = PGPalette[c(5,1,2,4)]) +
      facet_wrap(~cluster+day) +
      ggpubr::stat_compare_means() +
      ggbeeswarm::geom_beeswarm()
}

Plot_Profiles_SOM_clusters_day <- function(som.model, clusters, phos_mat, ncol_grid=4, specific_cluster = FALSE ){
    phos_mat_t <- Get_Mat_With_Assigned_Clusters(som.model, clusters, phos_mat)
    phos_mat_t <- phos_mat_t
  
  if(specific_cluster){
    phos_mat_t <- phos_mat_t %>% 
      filter(cluster==specific_cluster)
  }
  
  phos_mat_t %>% 
    filter(!is.na(cluster)) %>%
      #filter(cluster==19) %>%
      mutate(prep = unlist(prep_l[sample]) ) %>%
      ggplot(aes( sample, log2FC, fill = day, group = peptide )) +
      geom_line(alpha = 0.3) +
      theme_bw() +
      theme(axis.text.x = element_text(angle = 90),
            axis.title.x = element_blank()) +
      scale_color_manual(values = PGPalette[c(5,1,2,4)]) +
      facet_wrap(~cluster, ncol = ncol_grid) +
    geom_point(alpha = 0.3, aes(col = day), size = 0.4)
}

Plot_Profiles_SOM_clusters_day_sorted_by_day <- function(som.model, clusters, phos_mat, ncol_grid=4, specific_cluster = FALSE ){
    phos_mat_t <- Get_Mat_With_Assigned_Clusters(som.model, clusters, phos_mat)
    phos_mat_t <- phos_mat_t
  
  if(specific_cluster){
    phos_mat_t <- phos_mat_t %>% 
      filter(cluster==specific_cluster)
  }
  
  phos_mat_t <- phos_mat_t %>% 
    filter(!is.na(cluster)) %>%
      #filter(cluster==19) %>%
      mutate(prep = unlist(prep_l[sample]) )
  order_prep <- phos_mat_t %>%
    arrange( day, treatment, prep ) %>%
    .$sample
  phos_mat_t %>% 
      mutate(sample = as.factor(sample)) %>%
      mutate(sample = factor(sample, levels = unique(order_prep)) ) %>%
      ggplot(aes( sample, log2FC, fill = day, group = peptide )) +
      geom_line(alpha = 0.3) +
      theme_bw() +
      theme(axis.text.x = element_text(angle = 90),
            axis.title.x = element_blank()) +
      scale_color_manual(values = PGPalette[c(5,1,2,4)]) +
      facet_wrap(~cluster, ncol = ncol_grid) +
    geom_point(alpha = 0.3, aes(col = day), size = 0.4)
}

Confusion_Matrix <- function(cluster){
  as.data.frame(Asign_To_Clusters(som.model.pat, cluster) ) %>% 
  rownames_to_column("sample") %>% 
  separate(sample, sep = "_", into = c("log2FC", "xenograft", "treatment", "day", "replicate", "set" )  ) %>%
  select(-day, -set, -xenograft, -log2FC, -replicate) %>%
  table
}


Confusion_Matrix_Prep <- function(cluster){
  as.data.frame(Asign_To_Clusters(som.model.pat, cluster) ) %>% 
  rownames_to_column("sample") %>% 
  mutate(prep = unlist( prep_l[ gsub("log2FC_", "", sample)]) ) %>%
  separate(sample, sep = "_", into = c("log2FC", "xenograft", "treatment", "day", "replicate", "set" )  ) %>%
  select(-day, -set, -xenograft, -log2FC, -replicate, -treatment) %>%
  table
}

StringDB

Plot_StringDB <- function(hits){
  hits <- as.data.frame(hits)
  colnames(hits) <- "HGNC_Symbol"
  hits_mapped <- string_db$map( hits, "HGNC_Symbol", removeUnmappedRows = TRUE )
  string_db$plot_network( hits_mapped)
}

SOMs

Peptide - pY

train the SOM

som.pept.pY <- Train_SOM(phos_mat= t(pY_mat_Set1), try.k = 2:40)

som.model.pept.pY <- som.pept.pY[[1]]
som.events.pept.pY <- som.pept.pY[[2]]

evaluate clustering algorithms

## Having selected a reasonable value for k, evaluate different clustering algorithms.

## Try several different clustering algorithms, and, if desired, different values for k
cluster.tries.pept.pY <- list()

for(k in c(3,4,5, 10, 15, 25)){
  ## k-means clustering
  
  som.cluster.k <- kmeans(som.events.pept.pY, centers = k, iter.max = 100, nstart = 10)$cluster # k-means
  
  ## hierarchical clustering
  
  som.dist.pept <- dist(som.events.pept.pY) # hierarchical, step 1
  som.cluster.h <- cutree(hclust(som.dist.pept), k = k) # hierarchical, step 2
  
  ## capture outputs
  cluster.tries.pept.pY[[paste0('som.cluster.k.', k)]] <- som.cluster.k
  cluster.tries.pept.pY[[paste0('som.cluster.h.', k)]] <- som.cluster.h
}

## Take a look at the various clusters.  You're looking for the algorithm that produces the
## least fragmented clusters.

message("k10")
## k10
Plot_Colored_SOM(som.model.pept.pY, 
                 cluster.tries.pept.pY$som.cluster.k.10, cl = 25)

message("k15")
## k15
Plot_Colored_SOM(som.model.pept.pY, 
                 cluster.tries.pept.pY$som.cluster.k.15, cl = 25)

message("k29")
## k29
Plot_Colored_SOM(som.model.pept.pY, 
                 cluster.tries.pept.pY$som.cluster.k.25, cl = 25)

#cluster.tries.pept.pY$som.cluster.k.20

message("Members in each cluster (k15):")
## Members in each cluster (k15):
sort(table(Asign_To_Clusters(som.model.pept.pY, cluster.tries.pept.pY$som.cluster.k.15))) 
## 
##  2 11  5  9  1  4  3 15  6 12 13  8 14  7 10 
##  2  6 13 13 15 15 16 16 17 17 21 23 23 25 32
message("Members in each cluster (k29):")
## Members in each cluster (k29):
sort(table(Asign_To_Clusters(som.model.pept.pY, cluster.tries.pept.pY$som.cluster.k.25))) 
## 
## 24  6  8 16 25  1  7 12 23 11  2  9 10 17 22 15 20  4 13  3 18 21  5 19 14 
##  2  5  5  5  5  6  6  6  6  7  8  8  8  9 10 11 11 15 15 16 16 16 17 20 21
message("h3")
## h3
Plot_Colored_SOM(som.model.pept.pY, 
                 cluster.tries.pept.pY$som.cluster.h.3, cl = 5)

message("h4")
## h4
Plot_Colored_SOM(som.model.pept.pY, 
                 cluster.tries.pept.pY$som.cluster.h.4, cl = 5)

message("h5")
## h5
Plot_Colored_SOM(som.model.pept.pY, 
                 cluster.tries.pept.pY$som.cluster.h.5, cl = 5)

Abundance across all peptides

t(pY_mat_Set1) %>%
  as.data.frame(  ) %>%
  rownames_to_column( "peptide") %>%
  pivot_longer(-peptide, names_to = "sample", values_to = "log2FC") %>%
  mutate(sample = gsub( "log2FC_", "", sample)) %>%
  separate( sample , into = c("xenograft", "treatment", "day", "replicate", "set"), sep = "_", remove = F) %>%
  separate(peptide, into = c("HGNC_Symbol", "Annotated_Sequence"), sep =   "_", remove = F ) %>%
  group_by(sample, treatment, day, set, replicate) %>%
  summarise("Mean of cluster" = mean(log2FC)) %>%
  ungroup() %>%
  mutate(treatment = as.factor(treatment)) %>%
  ggplot(aes( treatment, `Mean of cluster`, fill = treatment )) +
  geom_boxplot(outlier.size = 0) +
  theme_bw() +
  theme(axis.text.x = element_text(angle = 90),
  axis.title.x = element_blank()) +
  scale_fill_manual(values = PGPalette[c(5,1,2,4)]) +
  ggbeeswarm::geom_beeswarm() +
  ggpubr::stat_compare_means()
## `summarise()` has grouped output by 'sample', 'treatment', 'day', 'set'. You
## can override using the `.groups` argument.

Analysis clusters

k 15

Profiles for all clusters
Plot_Profiles_SOM_clusters(som.model = som.model.pept.pY,
                           clusters = cluster.tries.pept.pY$som.cluster.k.15,
                           phos_mat = pY_mat_Set1)
## `summarise()` has grouped output by 'sample'. You can override using the
## `.groups` argument.

Plot_Profiles_SOM_Clusters_Splitbyday(som.model = som.model.pept.pY,
                           clusters = cluster.tries.pept.pY$som.cluster.k.15,
                           phos_mat = pY_mat_Set1)
## `summarise()` has grouped output by 'treatment', 'day', 'sample'. You can
## override using the `.groups` argument.
## Warning: Computation failed in `stat_compare_means()`:
## argument "x" is missing, with no default
## Computation failed in `stat_compare_means()`:
## argument "x" is missing, with no default
## Computation failed in `stat_compare_means()`:
## argument "x" is missing, with no default
## Computation failed in `stat_compare_means()`:
## argument "x" is missing, with no default
## Computation failed in `stat_compare_means()`:
## argument "x" is missing, with no default
## Computation failed in `stat_compare_means()`:
## argument "x" is missing, with no default
## Computation failed in `stat_compare_means()`:
## argument "x" is missing, with no default
## Computation failed in `stat_compare_means()`:
## argument "x" is missing, with no default
## Computation failed in `stat_compare_means()`:
## argument "x" is missing, with no default
## Computation failed in `stat_compare_means()`:
## argument "x" is missing, with no default
## Computation failed in `stat_compare_means()`:
## argument "x" is missing, with no default
## Computation failed in `stat_compare_means()`:
## argument "x" is missing, with no default
## Computation failed in `stat_compare_means()`:
## argument "x" is missing, with no default
## Computation failed in `stat_compare_means()`:
## argument "x" is missing, with no default
## Computation failed in `stat_compare_means()`:
## argument "x" is missing, with no default

Plot_Profiles_SOM_Clusters_Splitbyday(som.model = som.model.pept.pY,
                           clusters = cluster.tries.pept.pY$som.cluster.k.15,
                           phos_mat = pY_mat_Set1, 
                           specific_cluster = 9)
## `summarise()` has grouped output by 'treatment', 'day', 'sample'. You can
## override using the `.groups` argument.
## Warning: Computation failed in `stat_compare_means()`:
## argument "x" is missing, with no default

k15cl_pY <- Asign_To_Clusters(som.model.pept.pY, cluster.tries.pept.pY$som.cluster.k.15)
k15cl_pY[k15cl_pY == 9]
##             GAB1_DASSQDCyDIPR       CRKL_DSSTCPGDyVLSVSENSR 
##                             9                             9 
##     CTNND1_HYEDGYPGGSDNyGSLSR          MAPK12_QADSEMTGyVVTR 
##                             9                             9 
##   GAREM1_QWTTITAHSLEEGHyVIGPK            BCAR1_RPGPGTLyDVPR 
##                             9                             9 
##           GAREM1_SASySLESTDVK CDCP1_SPPESESEPyTFSHPNNGDVSSK 
##                             9                             9 
##        LCK_SVLEDFFTATEGQyQPQP     GAREM1_TDTNPSESTPVSCyPCNR 
##                             9                             9 
##            NEDD9_TGHGYVyEYPSR             PXN_VGEEEHVySFPNK 
##                             9                             9 
##              RET_VGPGyLGSGGSR 
##                             9
# PLSDA pY comp1
k15cl_pY[which(grepl("RET", names(k15cl_pY) )) ]
##            RET_ADGTNTGFPRyPNDSVYANWMLSPSAAK 
##                                          15 
##                              RET_DVyEEDSYVK 
##                                           4 
##                              RET_DVYEEDSyVK 
##                                          11 
##                             RET_DVyEEDSYVKR 
##                                           4 
##                             RET_DVYEEDSyVKR 
##                                          11 
##                     RET_LyGMSDPNWPGESPVPLTR 
##                                           4 
## RET_RRDyLDLAASTPSDSLIYDDGLSEEETPLVDCNNAPLPR 
##                                          15 
##                            RET_VGPGyLGSGGSR 
##                                           9 
##                      RET_YPNDSVyANWMLSPSAAK 
##                                           4

h 5

Profiles for all clusters
Plot_Profiles_SOM_clusters(som.model = som.model.pept.pY,
                           clusters = cluster.tries.pept.pY$som.cluster.h.5,
                           phos_mat = pY_mat_Set1)
## `summarise()` has grouped output by 'sample'. You can override using the
## `.groups` argument.

Plot_Profiles_SOM_Clusters_Splitbyday(som.model = som.model.pept.pY,
                           clusters = cluster.tries.pept.pY$som.cluster.h.5,
                           phos_mat = pY_mat_Set1)
## `summarise()` has grouped output by 'treatment', 'day', 'sample'. You can
## override using the `.groups` argument.
## Warning: Computation failed in `stat_compare_means()`:
## argument "x" is missing, with no default
## Computation failed in `stat_compare_means()`:
## argument "x" is missing, with no default
## Computation failed in `stat_compare_means()`:
## argument "x" is missing, with no default
## Computation failed in `stat_compare_means()`:
## argument "x" is missing, with no default
## Computation failed in `stat_compare_means()`:
## argument "x" is missing, with no default

h5cl_pY <- Asign_To_Clusters(som.model.pept.pY, cluster.tries.pept.pY$som.cluster.h.5)
message("Cluster 1")
## Cluster 1
names(h5cl_pY[h5cl_pY == 1])
##  [1] "RET_ADGTNTGFPRyPNDSVYANWMLSPSAAK"           
##  [2] "RPSA_ADHQPLTEASyVNLPTIALCNTDSPLR"           
##  [3] "ANXA2_AEDGSVIDyELIDQDAR"                    
##  [4] "LYN_AEERPTFDYLQSVLDDFyTATEGQYQQQP"          
##  [5] "TNS1_AGSLPNyATINGK"                         
##  [6] "LAMTOR1_ALNGAEPNyHSLPSAR"                   
##  [7] "SDC4_APTNEFyA"                              
##  [8] "CLTC_AVNyFSK"                               
##  [9] "FRK_DGSSQQLQGyIPSNYVAEDR"                   
## [10] "FLNB_DLDIIDNYDySHTVK"                       
## [11] "AFAP1L2_DNHLHFyQDR"                         
## [12] "RPS12_DVIEEyFK"                             
## [13] "KRT19_DYSHyYTTIQDLR"                        
## [14] "ITGB4_DySTLTSVSSHDSR"                       
## [15] "PLCG1_EHAFVASEyPVILSIEDHCSIAQQR"            
## [16] "LYN_EKAEERPTFDYLQSVLDDFYTATEGQyQQQP"        
## [17] "DDR1_EPPPyQEPRPR"                           
## [18] "MYH1_ESIFCIQyNVR"                           
## [19] "FAIM_ETFyVGAAK"                             
## [20] "EPHB4_FLEENSSDPTyTSSLGGK"                   
## [21] "PGAM1_FSGWyDADLSPAGHEEAK"                   
## [22] "PGAM1_FSGWyDADLSPAGHEEAKR"                  
## [23] "SLC38A2_FSISPDEDSSSYSSNSDFNySYPTK"          
## [24] "PTPN11_GHEyTNIK"                            
## [25] "SRSF9_GSPHyFSPFRPY"                         
## [26] "HSPD1_GYISPyFINTSK"                         
## [27] "DSC2_HAQDyVLTYNYEGR"                        
## [28] "ATG101_HEyLPK"                              
## [29] "BCAR1_HLLAPGPQDIyDVPPVR"                    
## [30] "MAPK14_HTDDEMtGyVATR"                       
## [31] "JUP_HVAAGTQQPyTDGVR"                        
## [32] "MAPK3_IADPEHDHTGFLtEyVATR"                  
## [33] "MAPK3_IADPEHDHTGFLTEyVATR"                  
## [34] "TTN_IDQLQEGCSYyFR"                          
## [35] "PLCG1_IGTAEPDyGALYEGR"                      
## [36] "CRKL_IHyLDTTTLIEPAPR"                       
## [37] "TSG101_KTAGLSDLy"                           
## [38] "DDR1_LLLATyARPPR"                           
## [39] "ACTR3_LPACVVDCGTGyTK"                       
## [40] "STAM2_LVNEAPVySVYSK"                        
## [41] "ANXA5_LYDAyELK"                             
## [42] "ANXA5_LYDAyELKHALK"                         
## [43] "SDCBP_LyPELSQYMGLSLNEEEIR"                  
## [44] "SDCBP_LYPELSQyMGLSLNEEEIR"                  
## [45] "WRNIP1_MLEGGEDPLyVAR"                       
## [46] "PEAK1_NAIKVPIVINPNAyDNLAIYK"                
## [47] "SNF8_NGyVTVSEIK"                            
## [48] "CDKL5_NLSEGNNANYTEyVATR"                    
## [49] "DDR1_NLyAGDYYR"                             
## [50] "DDR1_NLYAGDyYR"                             
## [51] "VCL_NPGNQAAyEHFETMK"                        
## [52] "HNRNPUL1_NYILDQTNVyGSAQR"                   
## [53] "PDGFRA_QADTTQyVPMLER"                       
## [54] "GJA1_QASEQNWANySAEQNR"                      
## [55] "ACP1_QLIIEDPyYGNDSDFETVYQQCVR"              
## [56] "SPTBN1_QNLLSQSHAyQQFLR"                     
## [57] "FTH1_QNyHQDSEAAINR"                         
## [58] "EPHA2_QSPEDVyFSK"                           
## [59] "BRK1_RIEyIEAR"                              
## [60] "RET_RRDyLDLAASTPSDSLIYDDGLSEEETPLVDCNNAPLPR"
## [61] "CLDN4_SAAASNyV"                             
## [62] "VCL_SFLDSGyR"                               
## [63] "MTMR10_SGPLEACyGELGQSR"                     
## [64] "SLC38A2_SHyADVDPENQNFLLESNLGK"              
## [65] "SLC38A2_SHyADVDPENQNFLLESNLGKK"             
## [66] "LSR_SSSAGGQGSyVPLLR"                        
## [67] "AFAP1L2_SSSSDEEYIyMNK"                      
## [68] "CAPZB_STLNEIyFGK"                           
## [69] "PKP4_STTNyVDFYSTK"                          
## [70] "TXNRD1_SYDyDLIIIGGGSGGLAAAK"                
## [71] "EFNB2_TADSVFCPHyEK"                         
## [72] "TSG101_TAGLSDLy"                            
## [73] "NUDT5_TLHyECIVLVK"                          
## [74] "CLTC_TSIDAyDNFDNISLAQR"                     
## [75] "EFNB1_TTENNYCPHyEK"                         
## [76] "EPHA2_TYVDPHTyEDPNQAVLK"                    
## [77] "MAPK1_VADPDHDHTGFLtEyVATR"                  
## [78] "MAPK1_VADPDHDHTGFLTEyVATR"                  
## [79] "HGS_VCEPCyEQLNR"                            
## [80] "CALM1_VFDKDGNGyISAAELR"                     
## [81] "HBA1_VGAHAGEyGAEALER"                       
## [82] "EPHA2_VLEDDPEATyTTSGGK"                     
## [83] "EPHA2_VLEDDPEATyTTSGGKIPIR"                 
## [84] "PEAK1_VPIVINPNAyDNLAIYK"                    
## [85] "LCP1_VyALPEDLVEVNPK"                        
## [86] "DSG2_VyAPASTLVDQPYANEGTVVVTER"              
## [87] "SERINC5_yAAPELEIAR"                         
## [88] "VTA1_yAGSALQYEDVSTAVQNLQK"                  
## [89] "PSMA6_yKYGYEIPVDMLCK"                       
## [90] "PTK2_YMEDSTyYK"                             
## [91] "ACTR3_ySYVCPDLVK"                           
## [92] "RPSA_yVDIAIPCNNK"                           
## [93] "CAV1_YVDSEGHLyTVPIR"                        
## [94] "TNK1_yVLARP"                                
## [95] "PTPRA_yVNILPYDHSR"                          
## [96] "LHPP_yYKETSGLMLDVGPYMK"
message("Cluster 2")
## Cluster 2
names(h5cl_pY[h5cl_pY == 2])
##   [1] "PKM_AEGSDVANAVLDGADCIMLSGETAKGDyPLEAVR"
##   [2] "DSP_AESGPDLRyEVTSGGGGTSR"              
##   [3] "MYH9_ALELDSNLyR"                       
##   [4] "NCOA4_ANEPCTSFAECVCDENCEKEALyK"        
##   [5] "AK2_APSVPAAEPEyPK"                     
##   [6] "PFN1_CyEMASHLR"                        
##   [7] "FAM20B_DHVVEGEPyAGYDR"                 
##   [8] "PIK3R1_DQyLMWLTQK"                     
##   [9] "CRK_DSSTSPGDyVLSVSENSR"                
##  [10] "ARPC3_DTDIVDEAIyYFK"                   
##  [11] "RET_DVyEEDSYVK"                        
##  [12] "RET_DVyEEDSYVKR"                       
##  [13] "PRKCD_DySNFDQEFLNEK"                   
##  [14] "AGL_EAMSAyNSHEEGR"                     
##  [15] "PRAG1_EATQPEPIyAESTK"                  
##  [16] "TLN2_ECDySIDGINR"                      
##  [17] "PGK1_ELNyFAK"                          
##  [18] "PDCD6IP_EPSAPSIPTPAyQSSPAGGHAPTPPTPAPR"
##  [19] "ARPC3_ETKDTDIVDEAIyYFK"                
##  [20] "ADAM9_EVPIyANR"                        
##  [21] "PIK3R2_EYDQLyEEYTR"                    
##  [22] "EPHB3_FLEDDPSDPTyTSSLGGK"              
##  [23] "PKM_GDyPLEAVR"                         
##  [24] "MAPK7_GLCTSPAEHQYFMTEyVATR"            
##  [25] "ENO2_GNPTVEVDLyTAK"                    
##  [26] "PTBP1_GQPIyIQFSNHK"                    
##  [27] "STAT1_GTGyIKTELISVSEVHPSR"             
##  [28] "GPRC5C_GVGyETILK"                      
##  [29] "DSP_GVITDQNSDGyCQTGTMSR"               
##  [30] "RASA1_HFTNPyCNIYLNSVQVAK"              
##  [31] "FRK_HGHyFVALFDYQAR"                    
##  [32] "ESYT1_HLSPyATLTVGDSSHK"                
##  [33] "TJP2_HPDIyAVPIK"                       
##  [34] "ACTN1_HRPELIDyGK"                      
##  [35] "C11orf52_HVHLENATEyATLR"               
##  [36] "ANXA3_HYGYSLySAIK"                     
##  [37] "GOT1_IANDNSLNHEyLPILGLAEFR"            
##  [38] "CDK1_IGEGTYGVVyKGR"                    
##  [39] "NAXD_IGVVGGCQEyTGAPYFAAISALK"          
##  [40] "CRK_IHyLDTTTLIEPVSR"                   
##  [41] "KCT2_ITNDyIF"                          
##  [42] "CLTC_IyIDSNNNPER"                      
##  [43] "PIK3C2B_IyLLPDPQK"                     
##  [44] "SKAP2_IyQFTAASPK"                      
##  [45] "PKM_IyVDDGLISLQVK"                     
##  [46] "PIK3CB_KQPYyYPPFDK"                    
##  [47] "PRPF4B_LCDFGSASHVADNDITPyLVSR"         
##  [48] "POTEJ_LCyVALDFEQEMAMVASSSSLEK"         
##  [49] "TAX1BP1_LELAEVQDNyK"                   
##  [50] "TAX1BP1_LELAEVQDNyKELK"                
##  [51] "CTNNB1_LHyGLPVVVK"                     
##  [52] "ITSN2_LIyLVPEK"                        
##  [53] "NCOA4_LLFQSyNVNDWLVK"                  
##  [54] "EPHB3_LQQyIAPGMK"                      
##  [55] "CTNNA1_LVyDGIR"                        
##  [56] "RET_LyGMSDPNWPGESPVPLTR"               
##  [57] "CPNE3_LyGPTNFSPIINHVAR"                
##  [58] "DYRK3_LYTyIQSR"                        
##  [59] "CTNNA1_NAGNEQDLGIQyK"                  
##  [60] "ARHGAP35_NEEENIySVPHDSTQGK"            
##  [61] "CTNNB1_NEGVATyAAAVLFR"                 
##  [62] "TMEM106B_NGDVSQFPyVEFTGR"              
##  [63] "LMO7_NHQLYCNDCyLR"                     
##  [64] "GOT2_NLDKEyLPIGGLAEFCK"                
##  [65] "LCK_NLDNGGFyISPR"                      
##  [66] "HNRNPL_NPNGPyPYTLK"                    
##  [67] "GDI2_NPyYGGESASITPLEDLYKR"             
##  [68] "INPPL1_NSFNNPAyYVLEGVPHQLLPPEPPSPAR"   
##  [69] "CASKIN2_NTyNQTALDIVNQFTTSQASR"         
##  [70] "WDR18_NyISAWELQR"                      
##  [71] "GRB2_NyVTPVNR"                         
##  [72] "SPTAN1_QGFVPAAyVK"                     
##  [73] "NUP93_QIyIYNEK"                        
##  [74] "FRK_QLLySENK"                          
##  [75] "CAP1_QVAYIyK"                          
##  [76] "LDHA_QVVESAyEVIK"                      
##  [77] "ANXA2_RAEDGSVIDyELIDQDAR"              
##  [78] "PRKCD_RSDsASSEPVGIyQGFEK"              
##  [79] "PRKCD_RSDSASSEPVGIyQGFEK"              
##  [80] "PRKCD_RSDSASSEPVGIyQGFEKK"             
##  [81] "DCP1A_SASPyHGFTIVNR"                   
##  [82] "PKP4_SAVSPDLHITPIyEGR"                 
##  [83] "ITPA_SAyALCTFALSTGDPSQPVR"             
##  [84] "IRS2_SDDyMPMSPASVSAPK"                 
##  [85] "PRKCD_SDSASSEPVGIyQGFEK"               
##  [86] "IDH1_SDyLNTFEFMDK"                     
##  [87] "MPZL1_SESVVyADIR"                      
##  [88] "SRSF1_SHEGETAyIR"                      
##  [89] "SRSF9_SHEGETSyIR"                      
##  [90] "CILK1_SKPPYtDyVSTR"                    
##  [91] "AFAP1L2_SKVAQQPLSLVGCEVVPDPSPDHLySFR"  
##  [92] "LYN_SLDNGGYyISPR"                      
##  [93] "AFAP1L2_SLETSSyLNVLVNSQWK"             
##  [94] "ANXA11_SLyHDISGDTSGDYR"                
##  [95] "AFAP1L2_SSSSDEEyIYMNK"                 
##  [96] "MAPK9_TACTNFMMTPyVVTR"                 
##  [97] "VDAC1_TDEFQLHTNVNDGTEFGGSIyQK"         
##  [98] "NUDT21_TINLyPLTNYTFGTK"                
##  [99] "TLN1_TMQFEPSTMVyDACR"                  
## [100] "SPRY4_TSHVENDyIDNPSLALTTGPK"           
## [101] "SSH2_TTNPFyNTM"                        
## [102] "HIPK3_TVCSTyLQSR"                      
## [103] "SKAP2_TVFYyYGSDKDK"                    
## [104] "AFAP1L2_VAQQPLSLVGCEVVPDPSPDHLySFR"    
## [105] "ITGB4_VCAYGAQGEGPySSLVSCR"             
## [106] "GAB1_VDyVVVDQQK"                       
## [107] "G6PD_VGFQyEGTYK"                       
## [108] "FLNA_VHSPSGALEECYVTEIDQDKyAVR"         
## [109] "WASL_VIyDFIEK"                         
## [110] "GPRC5C_VPSEGAyDIILPR"                  
## [111] "VASP_VQIyHNPTANSFR"                    
## [112] "G6PD_VQPNEAVyTK"                       
## [113] "PTPRA_VVQEYIDAFSDyANFK"                
## [114] "DSG2_VYAPASTLVDQPyANEGTVVVTER"         
## [115] "MYO1E_WTPIEyFNNK"                      
## [116] "STAT3_YCRPESQEHPEADPGSAAPyLK"          
## [117] "KRT8_yEELQSLAGK"                       
## [118] "PTPN11_yKNILPFDHTR"                    
## [119] "PTK2_yMEDSTYYK"                        
## [120] "RET_YPNDSVyANWMLSPSAAK"                
## [121] "ATP5PD_yPYWPHQPIENL"                   
## [122] "PTPRC_yVDILPYDYNR"
message("Cluster 3")
## Cluster 3
names(h5cl_pY[h5cl_pY == 3])
##  [1] "GAB1_DASSQDCyDIPR"             "CRKL_DSSTCPGDyVLSVSENSR"      
##  [3] "CTNND1_HYEDGYPGGSDNyGSLSR"     "MAPK12_QADSEMTGyVVTR"         
##  [5] "GAREM1_QWTTITAHSLEEGHyVIGPK"   "BCAR1_RPGPGTLyDVPR"           
##  [7] "GAREM1_SASySLESTDVK"           "CDCP1_SPPESESEPyTFSHPNNGDVSSK"
##  [9] "LCK_SVLEDFFTATEGQyQPQP"        "GAREM1_TDTNPSESTPVSCyPCNR"    
## [11] "NEDD9_TGHGYVyEYPSR"            "PXN_VGEEEHVySFPNK"            
## [13] "RET_VGPGyLGSGGSR"
message("Cluster 4")
## Cluster 4
names(h5cl_pY[h5cl_pY == 4])
##  [1] "PKP3_ADyDTLSLR"                 "RET_DVYEEDSyVK"                
##  [3] "RET_DVYEEDSyVKR"                "ANXA1_GGPGSAVSPyPTFNPSSDVAALHK"
##  [5] "PKP3_GQyHTLQAGFSSR"             "MAPK13_HADAEMTGyVVTR"          
##  [7] "MAPK14_HTDDEMTGyVATR"           "CTNND1_HYEDGyPGGSDNYGSLSR"     
##  [9] "MAPK11_QADEEMTGyVATR"           "PRKCD_TGVAGEDMQDNSGTyGK"       
## [11] "CRK_VPNAyDKTALALEVGELVK"        "PTPN11_VyENVGLMQQQK"
message("Cluster 5")
## Cluster 5
names(h5cl_pY[h5cl_pY == 5])
##  [1] "SHC1_ELFDDPSyVNVQNLDK"         "PIK3C2B_ENTHEATyIQR"          
##  [3] "JAK2_EVGDyGQLHETEVLLK"         "CDK5_IGEGTyGTVFK"             
##  [5] "PTPN11_IQNTGDyYDLYGGEK"        "PTK6_LSSFTSyENPT"             
##  [7] "PLCG1_NPGFyVEANPMPTFK"         "SYK_QESTVSFNPyEPELAPWAADKGPQR"
##  [9] "ARHGEF5_RTEELIyLSQK"           "GAB1_SSGSGSSVADERVDyVVVDQQK"  
## [11] "ARHGEF5_TEELIyLSQK"

Xenografts - pY

train the SOM

som.pat <- Train_SOM(phos_mat= pY_mat_Set1, try.k = 2:15)

som.model.pat <- som.pat[[1]]
som.events.pat <- som.pat[[2]]

evaluate clustering algorithms

## Having selected a reasonable value for k, evaluate different clustering algorithms.

## Define a function for make a simple plot of clustering output.
## This is the same as previousl plotting, but we define the function
## here as we wanted to play with the color earlier.

## Try several different clustering algorithms, and, if desired, different values for k

cluster.tries.pat.pY <- list()
for(k in c(5,6,7)){
  message(paste(k, "clusters"))
  ## k-means clustering
  som.cluster.k <- kmeans(som.events.pat, centers = k, iter.max = 100, nstart = 10)$cluster # k-means
  
  ## hierarchical clustering
  som.dist.pat <- dist(som.events.pat) # hierarchical, step 1
  som.cluster.h <- cutree(hclust(som.dist.pat), k = k) # hierarchical, step 2
  
  ## capture outputs
  cluster.tries.pat.pY[[paste0('som.cluster.k.', k)]] <- som.cluster.k
  cluster.tries.pat.pY[[paste0('som.cluster.h.', k)]] <- som.cluster.h
}
## 5 clusters
## 6 clusters
## 7 clusters

Hierarchical

## Take a look at the various clusters.  You're looking for the algorithm that produces the
## least fragmented clusters.
Plot_Colored_SOM(som.model.pat, cluster.tries.pat.pY$som.cluster.h.5)

Plot_Colored_SOM(som.model.pat, cluster.tries.pat.pY$som.cluster.h.6)

Plot_Colored_SOM(som.model.pat, cluster.tries.pat.pY$som.cluster.h.7)

Asign_To_Clusters(som.model.pat, cluster.tries.pat.pY$som.cluster.h.5)
##  log2FC_Xenograft_EC_24h_2_Set1  log2FC_Xenograft_EC_24h_5_Set1 
##                               2                               5 
##   log2FC_Xenograft_E_24h_4_Set1 log2FC_Xenograft_ctrl_5d_7_Set1 
##                               5                               2 
##  log2FC_Xenograft_EC_24h_1_Set1 log2FC_Xenograft_EBC_24h_3_Set1 
##                               5                               3 
## log2FC_Xenograft_ctrl_5d_3_Set1   log2FC_Xenograft_E_24h_1_Set1 
##                               4                               2 
##   log2FC_Xenograft_E_24h_2_Set1 log2FC_Xenograft_EBC_24h_2_Set1 
##                               2                               5 
## log2FC_Xenograft_EBC_24h_4_Set1   log2FC_Xenograft_E_24h_5_Set1 
##                               1                               2 
##   log2FC_Xenograft_E_24h_3_Set1 log2FC_Xenograft_ctrl_5d_5_Set1 
##                               5                               2 
##  log2FC_Xenograft_EC_24h_4_Set1  log2FC_Xenograft_EC_24h_3_Set1 
##                               3                               2 
## log2FC_Xenograft_EBC_24h_1_Set1 
##                               1
Asign_To_Clusters(som.model.pat, cluster.tries.pat.pY$som.cluster.h.6)
##  log2FC_Xenograft_EC_24h_2_Set1  log2FC_Xenograft_EC_24h_5_Set1 
##                               2                               5 
##   log2FC_Xenograft_E_24h_4_Set1 log2FC_Xenograft_ctrl_5d_7_Set1 
##                               5                               2 
##  log2FC_Xenograft_EC_24h_1_Set1 log2FC_Xenograft_EBC_24h_3_Set1 
##                               5                               3 
## log2FC_Xenograft_ctrl_5d_3_Set1   log2FC_Xenograft_E_24h_1_Set1 
##                               4                               2 
##   log2FC_Xenograft_E_24h_2_Set1 log2FC_Xenograft_EBC_24h_2_Set1 
##                               6                               5 
## log2FC_Xenograft_EBC_24h_4_Set1   log2FC_Xenograft_E_24h_5_Set1 
##                               1                               2 
##   log2FC_Xenograft_E_24h_3_Set1 log2FC_Xenograft_ctrl_5d_5_Set1 
##                               5                               2 
##  log2FC_Xenograft_EC_24h_4_Set1  log2FC_Xenograft_EC_24h_3_Set1 
##                               3                               2 
## log2FC_Xenograft_EBC_24h_1_Set1 
##                               1
Asign_To_Clusters(som.model.pat, cluster.tries.pat.pY$som.cluster.h.7)
##  log2FC_Xenograft_EC_24h_2_Set1  log2FC_Xenograft_EC_24h_5_Set1 
##                               2                               5 
##   log2FC_Xenograft_E_24h_4_Set1 log2FC_Xenograft_ctrl_5d_7_Set1 
##                               7                               2 
##  log2FC_Xenograft_EC_24h_1_Set1 log2FC_Xenograft_EBC_24h_3_Set1 
##                               7                               3 
## log2FC_Xenograft_ctrl_5d_3_Set1   log2FC_Xenograft_E_24h_1_Set1 
##                               4                               2 
##   log2FC_Xenograft_E_24h_2_Set1 log2FC_Xenograft_EBC_24h_2_Set1 
##                               6                               5 
## log2FC_Xenograft_EBC_24h_4_Set1   log2FC_Xenograft_E_24h_5_Set1 
##                               1                               2 
##   log2FC_Xenograft_E_24h_3_Set1 log2FC_Xenograft_ctrl_5d_5_Set1 
##                               7                               2 
##  log2FC_Xenograft_EC_24h_4_Set1  log2FC_Xenograft_EC_24h_3_Set1 
##                               3                               2 
## log2FC_Xenograft_EBC_24h_1_Set1 
##                               1
Confusion_Matrix(cluster.tries.pat.pY$som.cluster.h.5)
##          Asign_To_Clusters(som.model.pat, cluster)
## treatment 1 2 3 4 5
##      ctrl 0 2 0 1 0
##      E    0 3 0 0 2
##      EBC  2 0 1 0 1
##      EC   0 2 1 0 2
Confusion_Matrix(cluster.tries.pat.pY$som.cluster.h.6)
##          Asign_To_Clusters(som.model.pat, cluster)
## treatment 1 2 3 4 5 6
##      ctrl 0 2 0 1 0 0
##      E    0 2 0 0 2 1
##      EBC  2 0 1 0 1 0
##      EC   0 2 1 0 2 0
Confusion_Matrix(cluster.tries.pat.pY$som.cluster.h.7)
##          Asign_To_Clusters(som.model.pat, cluster)
## treatment 1 2 3 4 5 6 7
##      ctrl 0 2 0 1 0 0 0
##      E    0 2 0 0 0 1 2
##      EBC  2 0 1 0 1 0 0
##      EC   0 2 1 0 1 0 1
Confusion_Matrix_Prep(cluster.tries.pat.pY$som.cluster.h.5)
##                                          prep
## Asign_To_Clusters(som.model.pat, cluster) prep1 prep2
##                                         1     2     0
##                                         2     5     2
##                                         3     2     0
##                                         4     1     0
##                                         5     5     0

k-means

Plot_Colored_SOM(som.model.pat, cluster.tries.pat.pY$som.cluster.k.5, cl=7)

Plot_Colored_SOM(som.model.pat, cluster.tries.pat.pY$som.cluster.k.6, cl=7)

Plot_Colored_SOM(som.model.pat, cluster.tries.pat.pY$som.cluster.k.7, cl=7)

Asign_To_Clusters(som.model.pat, cluster.tries.pat.pY$som.cluster.k.5)
##  log2FC_Xenograft_EC_24h_2_Set1  log2FC_Xenograft_EC_24h_5_Set1 
##                               1                               4 
##   log2FC_Xenograft_E_24h_4_Set1 log2FC_Xenograft_ctrl_5d_7_Set1 
##                               4                               3 
##  log2FC_Xenograft_EC_24h_1_Set1 log2FC_Xenograft_EBC_24h_3_Set1 
##                               4                               1 
## log2FC_Xenograft_ctrl_5d_3_Set1   log2FC_Xenograft_E_24h_1_Set1 
##                               2                               3 
##   log2FC_Xenograft_E_24h_2_Set1 log2FC_Xenograft_EBC_24h_2_Set1 
##                               2                               4 
## log2FC_Xenograft_EBC_24h_4_Set1   log2FC_Xenograft_E_24h_5_Set1 
##                               5                               1 
##   log2FC_Xenograft_E_24h_3_Set1 log2FC_Xenograft_ctrl_5d_5_Set1 
##                               4                               3 
##  log2FC_Xenograft_EC_24h_4_Set1  log2FC_Xenograft_EC_24h_3_Set1 
##                               1                               3 
## log2FC_Xenograft_EBC_24h_1_Set1 
##                               5
Asign_To_Clusters(som.model.pat, cluster.tries.pat.pY$som.cluster.k.6)
##  log2FC_Xenograft_EC_24h_2_Set1  log2FC_Xenograft_EC_24h_5_Set1 
##                               1                               6 
##   log2FC_Xenograft_E_24h_4_Set1 log2FC_Xenograft_ctrl_5d_7_Set1 
##                               6                               3 
##  log2FC_Xenograft_EC_24h_1_Set1 log2FC_Xenograft_EBC_24h_3_Set1 
##                               6                               1 
## log2FC_Xenograft_ctrl_5d_3_Set1   log2FC_Xenograft_E_24h_1_Set1 
##                               2                               3 
##   log2FC_Xenograft_E_24h_2_Set1 log2FC_Xenograft_EBC_24h_2_Set1 
##                               4                               6 
## log2FC_Xenograft_EBC_24h_4_Set1   log2FC_Xenograft_E_24h_5_Set1 
##                               5                               1 
##   log2FC_Xenograft_E_24h_3_Set1 log2FC_Xenograft_ctrl_5d_5_Set1 
##                               6                               3 
##  log2FC_Xenograft_EC_24h_4_Set1  log2FC_Xenograft_EC_24h_3_Set1 
##                               1                               3 
## log2FC_Xenograft_EBC_24h_1_Set1 
##                               5
Asign_To_Clusters(som.model.pat, cluster.tries.pat.pY$som.cluster.k.7)
##  log2FC_Xenograft_EC_24h_2_Set1  log2FC_Xenograft_EC_24h_5_Set1 
##                               2                               3 
##   log2FC_Xenograft_E_24h_4_Set1 log2FC_Xenograft_ctrl_5d_7_Set1 
##                               1                               4 
##  log2FC_Xenograft_EC_24h_1_Set1 log2FC_Xenograft_EBC_24h_3_Set1 
##                               1                               2 
## log2FC_Xenograft_ctrl_5d_3_Set1   log2FC_Xenograft_E_24h_1_Set1 
##                               6                               4 
##   log2FC_Xenograft_E_24h_2_Set1 log2FC_Xenograft_EBC_24h_2_Set1 
##                               5                               3 
## log2FC_Xenograft_EBC_24h_4_Set1   log2FC_Xenograft_E_24h_5_Set1 
##                               7                               2 
##   log2FC_Xenograft_E_24h_3_Set1 log2FC_Xenograft_ctrl_5d_5_Set1 
##                               1                               4 
##  log2FC_Xenograft_EC_24h_4_Set1  log2FC_Xenograft_EC_24h_3_Set1 
##                               2                               4 
## log2FC_Xenograft_EBC_24h_1_Set1 
##                               7
Confusion_Matrix(cluster.tries.pat.pY$som.cluster.k.5)
##          Asign_To_Clusters(som.model.pat, cluster)
## treatment 1 2 3 4 5
##      ctrl 0 1 2 0 0
##      E    1 1 1 2 0
##      EBC  1 0 0 1 2
##      EC   2 0 1 2 0
Confusion_Matrix(cluster.tries.pat.pY$som.cluster.k.6)
##          Asign_To_Clusters(som.model.pat, cluster)
## treatment 1 2 3 4 5 6
##      ctrl 0 1 2 0 0 0
##      E    1 0 1 1 0 2
##      EBC  1 0 0 0 2 1
##      EC   2 0 1 0 0 2
Confusion_Matrix(cluster.tries.pat.pY$som.cluster.k.7)
##          Asign_To_Clusters(som.model.pat, cluster)
## treatment 1 2 3 4 5 6 7
##      ctrl 0 0 0 2 0 1 0
##      E    2 1 0 1 1 0 0
##      EBC  0 1 1 0 0 0 2
##      EC   1 2 1 1 0 0 0

Session Info

sessionInfo()
## R version 4.1.3 (2022-03-10)
## Platform: x86_64-apple-darwin17.0 (64-bit)
## Running under: macOS Big Sur/Monterey 10.16
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## attached base packages:
## [1] stats4    stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
##  [1] forcats_0.5.2               stringr_1.4.1              
##  [3] dplyr_1.0.10                purrr_0.3.5                
##  [5] readr_2.1.3                 tidyr_1.2.1                
##  [7] tibble_3.1.8                ggplot2_3.3.6              
##  [9] tidyverse_1.3.2             kohonen_3.0.11             
## [11] mdatools_0.13.0             SummarizedExperiment_1.24.0
## [13] GenomicRanges_1.46.1        GenomeInfoDb_1.30.1        
## [15] MatrixGenerics_1.6.0        matrixStats_0.62.0         
## [17] DEP_1.16.0                  org.Hs.eg.db_3.14.0        
## [19] AnnotationDbi_1.56.2        IRanges_2.28.0             
## [21] S4Vectors_0.32.4            Biobase_2.54.0             
## [23] BiocGenerics_0.40.0         fgsea_1.20.0               
## 
## loaded via a namespace (and not attached):
##   [1] utf8_1.2.2             shinydashboard_0.7.2   proto_1.0.0           
##   [4] gmm_1.7                tidyselect_1.2.0       RSQLite_2.2.18        
##   [7] htmlwidgets_1.5.4      grid_4.1.3             BiocParallel_1.28.3   
##  [10] norm_1.0-10.0          munsell_0.5.0          codetools_0.2-18      
##  [13] preprocessCore_1.56.0  chron_2.3-58           DT_0.26               
##  [16] withr_2.5.0            colorspace_2.0-3       highr_0.9             
##  [19] knitr_1.40             rstudioapi_0.14        ggsignif_0.6.4        
##  [22] mzID_1.32.0            labeling_0.4.2         GenomeInfoDbData_1.2.7
##  [25] farver_2.1.1           bit64_4.0.5            vctrs_0.5.0           
##  [28] generics_0.1.3         xfun_0.34              R6_2.5.1              
##  [31] doParallel_1.0.17      ggbeeswarm_0.6.0       clue_0.3-62           
##  [34] MsCoreUtils_1.6.2      bitops_1.0-7           cachem_1.0.6          
##  [37] DelayedArray_0.20.0    assertthat_0.2.1       promises_1.2.0.1      
##  [40] scales_1.2.1           googlesheets4_1.0.1    beeswarm_0.4.0        
##  [43] gtable_0.3.1           affy_1.72.0            sandwich_3.0-2        
##  [46] rlang_1.0.6            mzR_2.28.0             GlobalOptions_0.1.2   
##  [49] splines_4.1.3          rstatix_0.7.0          gargle_1.2.1          
##  [52] impute_1.68.0          broom_1.0.1            abind_1.4-5           
##  [55] BiocManager_1.30.19    yaml_2.3.6             modelr_0.1.9          
##  [58] backports_1.4.1        httpuv_1.6.6           tools_4.1.3           
##  [61] affyio_1.64.0          ellipsis_0.3.2         gplots_3.1.3          
##  [64] jquerylib_0.1.4        RColorBrewer_1.1-3     STRINGdb_2.6.5        
##  [67] MSnbase_2.20.4         gsubfn_0.7             Rcpp_1.0.9            
##  [70] hash_2.2.6.2           plyr_1.8.7             zlibbioc_1.40.0       
##  [73] RCurl_1.98-1.9         ggpubr_0.4.0           sqldf_0.4-11          
##  [76] GetoptLong_1.0.5       zoo_1.8-11             haven_2.5.1           
##  [79] cluster_2.1.4          fs_1.5.2               magrittr_2.0.3        
##  [82] data.table_1.14.4      circlize_0.4.15        reprex_2.0.2          
##  [85] googledrive_2.0.0      pcaMethods_1.86.0      mvtnorm_1.1-3         
##  [88] ProtGenerics_1.26.0    hms_1.1.2              mime_0.12             
##  [91] evaluate_0.17          xtable_1.8-4           XML_3.99-0.12         
##  [94] readxl_1.4.1           gridExtra_2.3          shape_1.4.6           
##  [97] compiler_4.1.3         KernSmooth_2.23-20     ncdf4_1.19            
## [100] crayon_1.5.2           htmltools_0.5.3        mgcv_1.8-41           
## [103] later_1.3.0            tzdb_0.3.0             lubridate_1.8.0       
## [106] DBI_1.1.3              dbplyr_2.2.1           ComplexHeatmap_2.10.0 
## [109] MASS_7.3-58.1          tmvtnorm_1.5           car_3.1-1             
## [112] Matrix_1.5-1           permute_0.9-7          cli_3.4.1             
## [115] vsn_3.62.0             imputeLCMD_2.1         parallel_4.1.3        
## [118] igraph_1.3.5           pkgconfig_2.0.3        MALDIquant_1.21       
## [121] xml2_1.3.3             foreach_1.5.2          vipor_0.4.5           
## [124] bslib_0.4.0            XVector_0.34.0         rvest_1.0.3           
## [127] digest_0.6.30          vegan_2.6-4            Biostrings_2.62.0     
## [130] rmarkdown_2.17         cellranger_1.1.0       fastmatch_1.1-3       
## [133] shiny_1.7.3            gtools_3.9.3           rjson_0.2.21          
## [136] lifecycle_1.0.3        nlme_3.1-160           jsonlite_1.8.3        
## [139] carData_3.0-5          limma_3.50.3           fansi_1.0.3           
## [142] pillar_1.8.1           lattice_0.20-45        KEGGREST_1.34.0       
## [145] fastmap_1.1.0          httr_1.4.4             plotrix_3.8-2         
## [148] glue_1.6.2             png_0.1-7              iterators_1.0.14      
## [151] bit_4.0.4              stringi_1.7.8          sass_0.4.2            
## [154] blob_1.2.3             caTools_1.18.2         memoise_2.0.1
knitr::knit_exit()